<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2019/1/15
 * Time: 14:24
 */

namespace app\api\behavior;


use app\api\model\Follow;
use app\lib\enum\FollowStatusEnum;

class FollowBehavior extends BaseBehavior
{
    public function actionBegin(&$params){
        $weight = $params['weight'];
        if ($weight == FollowStatusEnum::DEAL_TIME ){
            $data  = $params['data'];
            $content = '将预计成交时期设置为'.$data['close_time'];
        }
        if ($weight == FollowStatusEnum::DEAL_STATUS){
            $content = '用户已成交';
        }
        if ($weight == FollowStatusEnum::USER_LABEL){
            $content = '设置了用户标签';
        }
        if ($weight == FollowStatusEnum::TALK){
            $content = '与用户交流';
        }
        if ($weight == FollowStatusEnum::AMEND_USER_INFO){
            $content = '修改了用户信息';
        }
        if ($weight == FollowStatusEnum::PHONE){
            $content = '拨打了电话';
        }
        if ($weight == FollowStatusEnum::COUPON){
            $content = '领取了优惠券';
        }
        $info['user_id'] =$params['user_id'];
        $info['wu_id'] = $params['wu_id'];
        $info['url'] = request()->url();
        $info['weight'] = $weight;
        $info['content'] = $content;
        $follow = new Follow();
        $status =  $follow->createFollow($info);
        return $status;
    }
}